package org.sgx.gwtsjcl.client;

import com.google.gwt.core.client.JavaScriptObject;

/**
 * Miscellaneous. HMAC and PBKDF2.
 * 
 * @author sg
 * 
 */
public class Misc extends JavaScriptObject {
	protected Misc() {
	}

	/**
	 * Cached PBKDF2 key derivation.
	 * 
	 * @param password
	 *            the password
	 * @param params
	 *            derivation params (iteration count and optional salt).
	 * @return {Object} The derived data in key, the salt in salt.
	 */
	public native final EncryptParam cachedPbkdf2(String password, EncryptParam params) /*-{
		return this.cachedPbkdf2(password, params);
	}-*/;

	/**
	 * Password-Based Key-Derivation Function, version 2.0. Generate keys from passwords using PBKDF2-HMAC-SHA256. This is the method specified by RSA's PKCS #5 standard.
	 * 
	 * @param password
	 *            The password.
	 * @param salt
	 *            The salt. Should have lots of entropy.
	 * @param count
	 *            The number of iterations. Higher numbers make the function slower but more secure.
	 * @param length
	 *            The length of the derived key. Defaults to the output size of the hash function.
	 * @return the derived key.
	 */
	public native final BitArrayType pbkdf2(String password, BitArrayType salt, int count, int length) /*-{
		return this.pbkdf2(password, salt, count, length);
	}-*/;

}
